package org.singleton.dc;

/**
 * TODO
 * 黄金分割数列、兔子数列
 * 数列从第3项开始，每一项都等于前两项之和
 * @author singleton-zw
 * @date 2021/11/5 15:08
 */
public class Fibonacci {
    public static void main(String[] args) {
        System.out.println(fb(4));
    }

    public static long fb(int n){
        if (n < 1) {
            return 0;
        }
        if (n == 1 || n == 2) {
            return 1;
        }

        int[] arr = new int[n];
        arr[0] = arr[1] = 1;
        for (int i = 2; i < n; i++) {
            arr[i] = arr[i -2] + arr[i - 1];
        }

        return arr[n - 1];

    }

}
